package com.itheima.homework;

import java.util.Scanner;

public class Test03 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数组的长度(1-5)");

        while (true) {
            int len = sc.nextInt();
            if (len > 5 || len < 1) {
                System.out.println("你输入的数据有误");
            } else {
                int[] arr = new int[len];
                for (int i = 0; i < arr.length; i++) {
                    System.out.println("请输入第" + (i + 1) + "个元素,共" + arr.length + "个");
                    arr[i] = sc.nextInt();

                }
                System.out.println("录入完毕,结果如下");
                for (int i = 0; i < arr.length; i++) {
                    System.out.println(arr[i]);
                }
                break;
            }
        }
    }
}
